#ifndef _SOFT_PWM_H_
#define _SOFT_PWM_H_
#include "os_api.h"

typedef struct
{
    uint16_t period;
    uint16_t compare;
    void (*gpio_set)(uint8_t level);
    uint8_t  idle_level;
    uint8_t  cmp_level;
}soft_pwm_config_t;

typedef struct soft_pwm* soft_pwm_t;

soft_pwm_t soft_pwm_new(soft_pwm_config_t* config);
int soft_pwm_set_count(soft_pwm_t pwm, uint16_t count);
int soft_pwm_set_period(soft_pwm_t pwm, uint16_t period);
int soft_pwm_set_compare(soft_pwm_t pwm, uint16_t cmp);
int soft_pwm_get_status(soft_pwm_t pwm);
int soft_pwm_startup(soft_pwm_t pwm);
int soft_pwm_stop(soft_pwm_t pwm);
void soft_pwm_free(soft_pwm_t *pwm);
void soft_pwm_poll(void);
#endif


